/*
package com.itheima.reggie.aop;


import com.itheima.reggie.common.BaseContext;
import com.itheima.reggie.entity.CommonEntity;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
import java.time.LocalDateTime;

@Aspect
@Slf4j
@Component
public class CommonColumnAdvice {

    public CommonColumnAdvice(){
        log.info("===================================");
    }

    //对哪些类或者方法进行增强 切点表达式
    @Pointcut(
            "execution(* com.itheima.reggie.controller.*Controller.update*(..))" +
                    " || " +
                    " execution(* com.itheima.reggie.controller.*Controller.save*(..))"+
                    " || " +
                    " execution(* com.itheima.reggie.service.*Service.save*(..))"+
                    " || " +
                    " execution(* com.itheima.reggie.service.*Service.update*(..))"
    )
    public void pt(){}


    //增强的功能 ，对四个字段的值进行自动填充！！
    @Around("pt()")
    public Object modifyColumn(ProceedingJoinPoint pjp){
        log.info("aop 执行了....");
        Object proceed = null;
        try {
            // 拿到 Employee 参数对象
            Object[] args = pjp.getArgs();
            CommonEntity obj = (CommonEntity) args[0];// Employee Category ...
            String methodName = pjp.getSignature().getName();
            Long id = BaseContext.getCurrentId();
            if(methodName.startsWith("save")){//新增
                obj.setCreateTime(LocalDateTime.now());
                obj.setCreateUser(id);
            }
            obj.setUpdateTime(LocalDateTime.now());
            obj.setUpdateUser(id);
            proceed = pjp.proceed(args);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return proceed;

    }
}
*/
